home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / easyproc2.lha / EasyProcess / launch / WaitProc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.1 KB  |  59 lines

  1. #include "Launch.h"
  2. #include "LaunchPriv.h"
  3.  
  4.  
  5. /*
  6.  *    NAME
  7.  *        WaitProcess -- wait for a particular process to end.
  8.  *
  9.  *    SYNOPSIS
  10.  *        WaitProcess (Proc)
  11.  *
  12.  *        void WaitProcess (struct Process *);
  13.  *
  14.  *    DESCRIPTION
  15.  *        Check if the process pair list exists, check if the child
  16.  *        process exists and if it's alive.  Wait until it dies and
  17.  *        remove the process pair from the list, free the parent signal
  18.  *        and free the memory.
  19.  *
  20.  *        Free the list if it's empty.
  21.  *
  22.  *    INPUT
  23.  *        Proc - the child process to be waiting upon.
  24.  *
  25.  *    OUTPUT
  26.  *        None.
  27.  *
  28.  *    NOTE
  29.  *        You MUST be the parent of the process !!!
  30.  *
  31.  *    HISTORY
  32.  *        1992/09/06    Pierre Baillargeon        Creation
  33.  *
  34.  *    SEE ALSO
  35.  *        WaitProcesses(), WaitProcFunc()
  36.  */
  37.  
  38. void WaitProcess (struct Process *Proc)
  39. {
  40.     struct ProcPair *pp;
  41.  
  42.     Forbid ();
  43.     if (ProcPairList)
  44.     {
  45.         if (pp = IsChild (Proc))
  46.         {
  47.             while (pp->pp_ChildEntry)
  48.             {
  49.                 Wait (1L << pp->pp_ParentBit | KILL_PROCESS_FLAG);
  50.             }
  51.             Remove (pp);
  52.             FreeParentSignal (pp->pp_ParentBit);
  53.             FreeMem (pp, sizeof (struct ProcPair));
  54.         }
  55.         FreeProcPairList ();
  56.     }
  57.     Permit ();
  58. }
  59.